/**
 *  @file SDLScoreKeeper.cpp
 *
 *  @date 22-dec-2009
 *  @author Ives van der Flaas
 */

#include <sstream>
#include <string>
#include <tr1/memory>
#include "SDLScoreKeeper.h"
#include "SDLZoomDrawer.h"

namespace si_sdl
{

SDLScoreKeeper::SDLScoreKeeper()
{
	fScoreText = std::tr1::shared_ptr<SDLTextRepresentation>(
					new SDLTextRepresentation(
							"0",
							"fonts/Vera.ttf",
							15,
							Color(255,255,255),
							transparant,
							ALIGN_RIGHT));
}

SDLScoreKeeper::~SDLScoreKeeper()
{
	// TODO Auto-generated destructor stub
}

void SDLScoreKeeper::scoreChanged(int newScore)
{
	std::stringstream ss;
	ss << newScore;
	std::string scoreStr;
	ss >> scoreStr;

	fScoreText = std::tr1::shared_ptr<SDLTextRepresentation>(
						new SDLTextRepresentation(
								scoreStr,
								"fonts/Vera.ttf",
								15,
								Color(255,255,255),
								transparant,
								ALIGN_RIGHT));
}

void SDLScoreKeeper::draw()
{
	si::Vector2 screenSize = SDLZoomDrawer::get()->requestDrawableRegion();

	fScoreText->draw(
			si::Vector2(
					screenSize.getX() - fScoreText->getSize().getX()-5,
					5),
			si::Vector2(0,0));
}

}
